/**
 * 功能描述 导航
 */

define(function (require, exports, module) {
	var Component = require("subnav");
	var subnavEvents = require("../handler/subnavEvents");
	var user = require("store").get("user");
	
    var instance = {
        initComponent: function (params, widget) {
            var component = new Component({
            	parentNode:".J-subnav",
				model : {
					title:"报名收费",
					items : [{
					      id :"servicePoint",
					      type : "buttongroup",
					      all : {
					    	  show:false,
					    	  first:true
					      },
					      tip : "服务点",
					      keyField :"pkServicePoint",
					      valueField : "name",
//					      url : "api/servicepoint/operableservicepoints",
					      items:user.privateServicePoints,
					      params : function(){
					    	  return{
					    		  fetchProperties:"pkServicePoint,name"
					    	  }
					      },
					      handler : function(key,element){
					    	  widget.get("grid").refresh();
					      }
				    },{
						id : "startDate",
						type : "daterange",
						tip:"开始时间",
						ranges : {
					        "本年": [moment().startOf("year"), moment().endOf("days")]
						},
						handler : function(time){
							 widget.get("grid").refresh();
						}
					},{
						id : "destination",
						type : "buttongroup",
						url : "api/destination/query",
						all : {
							show : true,
							first : true
						},
						tip:"目的地",
						keyField:"pkDestination",
						params:function(){
							return{
								fetchProperties:"pkDestination,name",
							}
						},
						valueField:"name",
						handler:function(){
							widget.get("grid").refresh();
						}
					},{
						id : "status",
						tip:"状态",
						type:"buttongroup",
						items:[{
							key:"All",
							value:"全部"
						},{
							key:"Charge",
							value:"收费中"
						},{
							key:"ChargeComplete",
							value:"收费完成"
						},{
							key:"Review",
							value:"已复核"
						},{
							key:"Adjustment",
							value:"调整"
						},{
							key:"AdjustmentReview",
							value:"调整复核"
						}],
						handler:function(key,element){
							widget.get("grid").refresh();
						}
					},{
						id : "save",
						type : "button",
						text : "保存",
						show : false,
						handler : function(){
							subnavEvents.saveCharge(widget);
						}
					},{
						id : "cancel",
						type : "button",
						text : "返回",
						show : false,
						handler : function(){
							widget.hide([".J-form", ".J-editgrid", ".J-detailgrid"]).show(".J-grid");
							widget.get("subnav").hide(["save", "cancel"]).show(["startDate", "destination", "status", "servicePoint"]);
						}
					}]
				}
            });
            widget.set("subnav", component);
        }
    };
    module.exports = instance;
});
